﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ChromiumUpdater
{
    public partial class StatusDialog : Form
    {
        public int y = Screen.PrimaryScreen.WorkingArea.Height;
        bool fade;
        
        
        public StatusDialog(bool fadeIn, string message, string status, int time)
        {
            fade = fadeIn;
            
            InitializeComponent();
            this.TopMost = true;

            statusLbl.Text = status;
            messageLabel.Text = message;
            delayTimer.Interval = time;

            if (fade)
                openTimer.Enabled = true;
            else
            {               
                delayTimer.Enabled = true;
            }           
        }

        
        
        private void StatusDialog_Load(object sender, EventArgs e)
        {
            int x = Screen.PrimaryScreen.WorkingArea.Width - this.Width;
            y = Screen.PrimaryScreen.WorkingArea.Height - this.Height;
            this.Location = new Point(x, y);
            //for (int i = Screen.PrimaryScreen.WorkingArea.Height; i < this.Height; i--)
            //{
            //    int x = Screen.PrimaryScreen.WorkingArea.Width - this.Width;
            //    int y = i;
            //    this.Location = new Point(x, y);
            //}
        }

        private void closeTimer_Tick(object sender, EventArgs e)
        {
            int x = Screen.PrimaryScreen.WorkingArea.Width - this.Width;
            if (y <= Screen.PrimaryScreen.WorkingArea.Height)// - this.Height)
                y++;
            else
            {
                closeTimer.Enabled = false;
                this.Close();
                this.Dispose();
            }

            this.Location = new Point(x, y);
        }

        private void openTimer_Tick(object sender, EventArgs e)
        {
            int x = Screen.PrimaryScreen.WorkingArea.Width - this.Width;
            if (y > Screen.PrimaryScreen.WorkingArea.Height - this.Height)
                y--;
            else
            {
                openTimer.Enabled = false;
                delayTimer.Enabled = true;
            }

            this.Location = new Point(x, y);
        }

        private void delayTimer_Tick(object sender, EventArgs e)
        {
            if (fade)
            {
                delayTimer.Enabled = false;
                closeTimer.Enabled = true;
            }
            else
            {
                delayTimer.Enabled = false;
                this.Close();
                this.Dispose();
            }
        }

        //private string WrapText

    }
}
